import { connect } from 'react-redux'
import { useEffect } from 'react'
import { getInfo } from '../../redux/actions/user';
import './index.scss';
import { withRouter } from 'react-router';
import { Switch, Route, Redirect } from 'react-router-dom';


function Subject(props) {
  
    useEffect(() => {
        // 是否登录
        if (!localStorage.getItem('token')) {
            props.history.push('/login');
            return;
        }
        props.getInfo(props);
    }, []);
    const baseUrl = props.match.path;
    return (

        <div className="subject">
            {
                props.userInfo.role ? props.render(props.userInfo) : ''
            }
           
        </div>

    )
}
Subject = withRouter(Subject);
export default connect(state => ({ userInfo: state.userInfo }), { getInfo })(Subject);
